package top.frsf.mqtt.initializer;

import io.netty.channel.socket.SocketChannel;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import top.frsf.mqtt.codec.MqttServerCodec;
import top.frsf.mqtt.config.MqttHandlerContext;
import top.frsf.mqtt.handler.MqttServerHandler;
import top.frsf.mqtt.session.SessionManager;

/**
 * @author He Kuntao
 * @since 2025/5/26 14:52
 */
@Component
@RequiredArgsConstructor
public class ChannelInitializer extends io.netty.channel.ChannelInitializer<SocketChannel> {

    private final MqttHandlerContext mqttHandlerContext;

    @Override
    protected void initChannel(SocketChannel ch) {
        ch.pipeline()
                .addLast(new MqttServerCodec())
                .addLast(new MqttServerHandler(mqttHandlerContext));
    }
}
